<?php 
//$javascript->link('/cms/js/jquery.ajaxify.js',false);
//$javascript->link('/effects/js/jquery.form.js',false);
echo $javascript->link('/cms/js/jquery.ajaxify.js');
echo $javascript->link('/effects/js/jquery.form.js');
echo $javascript->link("/cms/js/jquery.validate.min.js");
?>

<div class="deals_newsletter_subscribe">
	<?php echo $form->create("DealSubscriber",array('url'=>$html->url('/deal_subscribers/subscribe'),'id'=>'deal_subscribe_frm')); ?>
	<strong><?php echo __("Receive deals for: "); ?></strong>
	<?php echo $form->input("city",array("type"=>"select","class"=>"city_dp","label"=>false,"div"=>false,"options"=>$cities)); ?>
	<?php if(!$session->read("Auth.User.id")) { ?>
	<?php echo $form->input("name",array("type"=>"text",'label'=>'Name','class'=>'required')); ?>
	<?php echo $form->input("email",array("type"=>"text",'label'=>__('Enter your e-mail address'),'class'=>'required email')); ?>
	<?php } ?>
	<?php echo $form->end("Subscribe",array("div"=>false)); ?>
	<script type="text/javascript">
		$(document).ready(function(){
			$("#deal_subscribe_frm").validate();

			
			$("#deal_subscribe_frm input[type='submit']").click(function(){
				if($("#deal_subscribe_frm").valid())
				{
					$("#deal_subscribe_frm").ajaxSubmit({
						success: function(status) {
							<?php if(!$session->read("Auth.User.id")) { ?>
							$("#DealSubscriberName").val("");
							$("#DealSubscriberEmail").val("");
							<?php } ?>
						}
					});
				}
				return false;
			});
		});
	</script>
</div>